class Solution {
public:
    vector<int> minSubsequence(vector<int>& nums) {
        sort(nums.begin(), nums.end());
        int sum = reduce(nums.begin(), nums.end());
        int n = nums.size();

        int accum = 0;
        vector<int> ans;
        for(int i = n - 1; i >= 0; --i)
        {
            accum += nums[i];
            int tmp = sum - accum;
            ans.push_back(nums[i]);
            if(accum > tmp)
                break;
        }
        return ans;
    }
};
